import React, { Component } from 'react';
import {
	StyleSheet, Text, FlatList,
	PixelRatio, View, Image, TouchableOpacity, Alert, ScrollView
} from "react-native";
import { API, API_GENERATE } from '../../../config/api';
import { GLOBAL } from '../../../config/global';
import { style } from '../../../theme/style';
import { Common } from '../../../component/common/Common.js';
import { PageStatusIndex } from '../../../component/page-status/PageStatusIndex';
import { RefuseModal } from '../../../component/ModalVerifylComponent.js';
import Dictionary from '../../../utils/dictionary';
import HTTP from '../../../utils/http';
import ToastUtil from '../../../utils/toast';
import { NavigationEvents } from 'react-navigation';
import { SearchInput } from '../../../component/SearchInput.js';
import MethodUtil from '../../../utils/MethodUtil';
import { StateLightBox } from '../../../component/Store';
import QuoteService from './_common/service.js';
import { RangTime } from '../../../component/common/RangTime.js';
import StorageHelper from '../../../utils/storageHelper';
import { STORAGE_CONSTANT } from '../../../config/storage';
import { NewAccountHome } from '../../../components/common/newAccountHome';
import { SlideSelect } from '../../../components/common/slideSelect';
import { CommonDialog } from '../../../components/common/Dialog';

const scale = GLOBAL.SCALE;
const sendApprovalDate = {};
const sendApprovalDateSing = {};
const maxCount = 20;//批量审批一次性最多审批条数
let sendData = {
	onrefresh: false,
	pageNo: 1,
	pageSize: 20,
	organId: null,
};

export class ApprovalPage extends Component {
	static navigationOptions = ({ navigation, navigationOptions }) => {
		const { params } = navigation.state;
		return {
			headerTitle: params ? params.title : '现货价审批',
			headerTintColor: style.color.white,
			headerLeft: <Common type="headLeft" onPress={() => { navigation.goBack() }} color='#fff' />,
			headerRight: (<Image style={style.head.headRightEmpty} source={require('../../../imgs/goBackEmpty.png')} />),
			headerStyle: style.head.headerStyle,
			headerTitleStyle: {
				flex: 1,
				textAlign: 'center'
			}
		}
	};

	requesting;
	constructor(props) {
		super(props);
		this.state = {
			tabIndex: 0,
			newLotData: [],  // 待审批
			status: 'loading',
			loadIcon: false,  // 下拉涮新的 图标
			selectIndex: '',
			applyIdChecked: {},
			modalVisible: false, //  部门顶部下拉
			modalVisible1: false, //  顶部下拉
			selectCheck: false,
			refuseModalVisible: false,
			resultModalVisible: false,
			companyData: [{ dictName: '全部', dictKey: null }],
			timeModel: false,//时间显示,
			timeStart: null,
			timeEnd: null,
			alertShow: false,
			options: [],
			choice: {},
			modalInfoVisible: false,
			companyIndex: 0,
		}
		this.pageNo = 1;
		this.totalPage = 1;
		this.headIndex = 0;
		this.department = null;//部门条件


		this.productData = [

		]
		this.productIndex = 0;
		this.product = '商品';



		this.stateLightBoxData = {
			onClosePress: this._closeLightBox,
			modalVisible: false,
			title: '审批进度',
			rowDataList: [],
		};

	}

	async componentWillMount() {
		this.props.navigation.setParams({
			title: '现货价审批'
		});
		// await this.getSorage();
		await this._getListData();
		await this._getCompanyData();//公司列表
	}


	//勾选函数
	_toggleUserIdChecked = (applyId) => {
		const { applyIdChecked } = this.state;
		const val = applyIdChecked[applyId] ? 0 : 1;
		applyIdChecked[applyId] = val;
		this.setState({
			applyIdChecked
		});
	}

	//全选函数
	_checkAll() {
		const { applyIdChecked, newLotData, selectCheck } = this.state;
		newLotData.forEach((item, i) => {
			if (i < maxCount) {
				var applyId = item['taskId'];
				applyIdChecked[applyId] = selectCheck ? 0 : 1;
			}
		});
		this.setState({
			applyIdChecked,
			selectCheck: (selectCheck ? false : true)
		});
	}
	//获取待审批,已审批列表
	async _getListData(agentObj) {
		this.setState({
			applyIdChecked: {}
		});
		const { timeStart, timeEnd } = this.state
		Object.assign(sendData, agentObj);
		let sendCount = {}
		sendData.startDate = timeStart;
		sendData.endDate = timeEnd;
		sendData.goodsName = this.goodsName;

		sendCount.goodsName = this.goodsName
		this.setState({
			loadIcon: true
		})
		let options = await HTTP.POST(API_GENERATE(API.MUL_PRICE_LOT), sendCount);
		options = options || [];
		options.map(item => {
			item.rowCount = item.paginationModel.recordCount
		})
		let { corpId } = options[this.state.companyIndex] || {};
		sendData.corpId = corpId || '';
		let responseData = await HTTP.POST(API_GENERATE(API.PRICE_LOT), sendData, {
			rejectError: true,
			handleError: true,
		});

		this.setState({
			options,
			choice: options[this.state.companyIndex] || {},
			loadIcon: false
		});
		if (responseData) {
			this.totalPage = responseData.totalPage;
			if (sendData.onrefresh) {  // 加载
				this.setState({
					newLotData: this.state.newLotData.concat(responseData.rows),
					status: 'data'
				})
			} else { // 刷新
				this.setState({
					newLotData: responseData.rows,
					status: responseData.rows.length ? 'data' : 'empty'
				})
			}
		} else {
			this.setState({
				status: 'error'
			})
		}
	}

	// 下拉更新函数
	_isLoadRefresh() {
		sendData.onrefresh = false,
			this._getListData();
	}
	//上拉加载
	_loadData() {
		if (this.totalPage > this.pageNo) {
			this.pageNo++;
			this._getListData({
				pageNo: this.pageNo,
				onrefresh: true
			});
		}
	}
	async _getCompanyData() {
		let { choice, companyData } = this.state || {};
		let { corpId } = choice || {};
		let dictionaryData = await QuoteService.findSq() || [];
		dictionaryData.forEach(element => {
			if (corpId == element.corpId) {
				companyData.push({ dictKey: element.organId, dictName: element.organName })
			}
		});

		//初始化清空
		this.headIndex = 0;
		this.department = null;
		sendData.organId = null;

		this.setState({
			companyData: companyData
		})

		var data = [];
		data[0] = { dictName: '全部', dictKey: null };
		companyData.forEach((item, i) => {
			var dictName = item['dictName'];
			data[(i * 1 + 1)] = { title: dictName, dictKey: (i * 1 + 1) };
		});
		this.headData = data;
	}


	//数据加载出错回调
	_onErrorPress = () => {
		this.setState({
			status: 'loading'
		}, function () {
			this._getListData();
		})
	}

	simpleFormatAsMoney(mnt) {
		// mnt -= 0;
		mnt = mnt ? (Math.round(mnt * 100)) / 100 : undefined;
		return (mnt == Math.floor(mnt)) ? mnt + '.00' : ((mnt * 10 == Math.floor(mnt * 10)) ? mnt + '0' : mnt);
	}
	// 一条数据
	_selectCallBack = (index) => {
		this.setState({
			selectIndex: index
		}, () => {
			setTimeout(() => {

			}, 100)
		})
	}

	//备注点击显示
	_showMark = (markBody) => {
		this.setState({
			modalRemark: true,
			markBody
		})
	}

	//关闭备注
	_closeMarkModel = () => {
		this.setState({
			modalRemark: false
		})
	}

	// 备注showdemo
	_retuenMarkModel = () => {
		let { markBody } = this.state;
		return (
			<View style={styles.markBox}>
				<Text style={styles.markTitle}>备注</Text>
				<ScrollView>
					<Text style={styles.markBody}>{markBody}</Text>
				</ScrollView>
			</View>
		)
	}

	_compare = (num1, num2) => {
		return MethodUtil.countObj.subtract(num1 || 0, num2 || 0);
	}


	_renderItem(data) {
		let { auditResultName, taskId, taskName, spotPriceApply, formKey, businessKey, processInstanceId } = data.item;
		let { bizStaffName, applyId, goodsName, yesdayPrice, status, prodDate, branchName, bizTeamName,
			suggestedPrice, createTime, lastPrice, remark } = spotPriceApply || {};
		let { tabIndex } = this.state;

		let downImg = require('../../../imgs/my-siter/down.png');
		let upImg = require('../../../imgs/my-siter/up.png');

		let rightImg = require('../../../imgs/global/success.png');
		let emptyImg = require('../../../imgs/global/option.png');

		const { applyIdChecked } = this.state;
		const optionSource = (applyIdChecked[taskId] && applyIdChecked[taskId] == 1) ? rightImg : emptyImg;

		if (suggestedPrice) {
			suggestedPrice = suggestedPrice.toString() || '0';
		}

		let range1 = this._compare(suggestedPrice, lastPrice);
		let range2 = this._compare(suggestedPrice, yesdayPrice);

		prodDate = prodDate && prodDate.split(' ')[0];

		return (

			<View style={{ flex: 1, alignItems: 'center' }}>
				<View style={styles.itemBox}>
					<View style={styles.itemBoxHeadView}>
						<View style={styles.itemBoxHead}>
							<TouchableOpacity style={styles.bombBody} onPress={() => { this._toggleUserIdChecked(taskId) }}>
								<Image style={styles.bombImg} source={optionSource} />
								<Text style={styles.itemHeadTitle} numberOfLines={1}>{goodsName}</Text>
							</TouchableOpacity>
							<Text style={styles.itemHeadTime}>{createTime}</Text>
						</View>
						<Text style={{ fontSize: 10 * scale, paddingLeft: 12 * scale, paddingBottom: 12 * scale, color: '#848A96' }}>(业务组织：{this.state.choice.corpName || '-'})</Text>
					</View>
					<View style={[styles.itemBody, { paddingTop: 15 * scale }]}>
						<View style={[styles.itemLine, styles.padding]}>
							<Text style={[styles.itemLineLay, styles.itemLineActive]}>本次报价</Text>
							<View style={styles.itemLine}>
								<Text style={[styles.itemLineVal, styles.itemLineNum]}>¥{suggestedPrice || '-'}</Text>
								<TouchableOpacity style={styles.tipTextBox} onPress={() => { this.setState({ modalInfoVisible: true }) }}>
									<Image style={styles.tipText} source={require('../../../imgs/global/query.png')} />
								</TouchableOpacity>
							</View>
						</View>

						<View style={[styles.itemLine, , styles.padding, styles.itemLineB]}>
							<View style={styles.itemLine}>
								<Text style={[styles.itemLineLay, styles.itemLineActive]}>较上次涨跌幅</Text>
								<View style={styles.itemLine}>
									<Image source={range1 >= 0 ? upImg : downImg} style={{ marginRight: 3 * scale, height: 14 * scale }} />
									<Text style={[styles.itemLineVal, styles.itemLineActive, range1 >= 0 ? styles.itemFormTextRed : styles.itemFormTextBlue]}>{range1}</Text>
								</View>
							</View>
							<View style={styles.itemLine}>
								<View>
									<Text style={[styles.itemLineLay]}>上次现货价</Text>
									{/* <Text style={[styles.itemLineLay, styles.itemLineTime]}>(2020-02-22)</Text> */}
								</View>
								<Text style={[styles.itemLineVal]}>￥{lastPrice || '-'}</Text>
							</View>
						</View>

						<View style={[styles.itemLine, styles.padding, styles.itemLineB]}>
							<View style={styles.itemLine}>
								<Text style={[styles.itemLineLay, styles.itemLineActive]}>较昨日涨跌幅</Text>
								<View style={styles.itemLine}>
									<Image source={range2 >= 0 ? upImg : downImg} style={{ marginRight: 3 * scale, height: 14 * scale }} />
									<Text style={[styles.itemLineVal, styles.itemLineActive, range2 >= 0 ? styles.itemFormTextRed : styles.itemFormTextBlue]}>{range2}</Text>
								</View>
							</View>
							<View style={styles.itemLine}>
								<Text style={[styles.itemLineLay]}>昨日现货价</Text>
								<Text style={[styles.itemLineVal]}>￥{yesdayPrice || '-'}</Text>
							</View>
						</View>

						<View style={[styles.itemLine, styles.padding]}>
							<Text style={[styles.itemLineLay]}>报价日期</Text>
							<View style={styles.itemLine}>
								<Text style={styles.itemLineVal}>{prodDate}</Text>
							</View>
						</View>

						<View style={[styles.itemLine,]}>
							<Text style={styles.itemLineLay}>提报人</Text>
							<View style={styles.flexLine}>
								<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
									<Text style={[styles.itemLineVal, { lineHeight: 20 * scale }]}>{bizStaffName ? bizStaffName + ' | ' : '--'}</Text>
									<Text style={[styles.itemLineVal, { lineHeight: 20 * scale }]}>{bizTeamName ? bizTeamName + ' | ' : '--'}</Text>
									<Text style={[styles.itemLineVal, { lineHeight: 20 * scale }]}>{branchName ? branchName + '' : '--'}</Text>
									<TouchableOpacity style={{ padding: 5 * scale, paddingVertical: 2 * scale, marginTop: -3 * scale }}>
										<Text onPress={() => { remark && this._showMark(remark) }} style={[styles.itemFormTextThem, { fontSize: 16 * scale, }]}>{remark && ' 备 '}</Text>
									</TouchableOpacity>
								</View>
							</View>
						</View>



						{/* <View style={styles.itemForm}>
							<View style={[styles.itemFormItem, styles.flex1, { paddingRight: 10 * scale }]}>
								<Text style={styles.itemFormTitle}>本次报价</Text>
								<View style={styles.bombBody}>
									<Text style={styles.itemFormText}>￥{suggestedPrice}</Text>
									<Image source={range >= 0 ? upImg : downImg} style={{ marginLeft: 5 * scale }} />
									<Text style={styles.itemFormTextRed}>{range}</Text>
									<TouchableOpacity style={styles.tipTextBox} onPress={() => { this.setState({ modalInfoVisible: true }) }}>
										<Image style={styles.tipText} source={require('../../../imgs/global/query.png')} />
									</TouchableOpacity>
								</View>
							</View>
							<View style={[styles.itemFormItem, styles.flex1]}>
								<Text style={styles.itemFormTitle}>当前现货价</Text>
								{
									lastPrice ? (<Text style={styles.itemFormText}>￥{lastPrice}</Text>) : (<Text style={styles.itemFormText}>-</Text>)
								}
							</View>
							<View style={[styles.itemFormItem, styles.flex1]}>
								<Text style={styles.itemFormTitle}>昨日现货价</Text>
								{
									yesdayPrice ? (<Text style={styles.itemFormText}>￥{yesdayPrice}</Text>) : (<Text style={styles.itemFormText}>-</Text>)
								}
							</View>
						</View>
						<View style={styles.itemForm2}>
							<View style={[styles.itemFormItem, styles.flex1]}>
								<Text style={styles.itemFormTitle}>报价日期</Text>
								<Text style={styles.itemFormText}>{prodDate}</Text>
							</View>
							<View style={[styles.itemFormItem, styles.flex2]}>
								<Text style={styles.itemFormTitle}>提报人</Text>
								<View style={styles.itemFormItem2}>
									<Text style={[styles.itemFormText]}>{bizStaffName} | {branchName}</Text>
									<Text onPress={() => { remark && this._showMark(remark) }} style={[styles.itemFormText, styles.itemFormTextThem, { fontSize: 16 * scale, padding: 5 * scale, marginTop: -5 * scale, marginLeft: 2 * scale, }]}>{remark && '备'}</Text>
								</View>
							</View>
						</View> */}
						<View style={styles.btnBoxParent}>
							<Text onPress={() => { this._stepFn(applyId, processInstanceId) }} style={[styles.itemFormText, styles.itemFormTextThem]}>查看审批流</Text>
							<View style={styles.btnBox}>
								<TouchableOpacity style={styles.btnBlueBox}
									onPress={() => {
										this.formKey = formKey;
										this.taskId = taskId;
										this.taskName = taskName;
										this.businessKey = businessKey;
										this.isAgree = true;
										this.setState({
											refuseModalVisible: true
										})

									}}>
									<Text style={styles.btnBlue} >通过</Text>
								</TouchableOpacity>
								<TouchableOpacity style={[styles.btnEmptyBox, {
									borderColor: style.color.themeColor, borderWidth: 1 * scale,
									borderStyle: 'solid',
								}]} onPress={() => {
									this.formKey = formKey;
									this.taskId = taskId;
									this.taskName = taskName;
									this.businessKey = businessKey;
									this.isAgree = false;
									this.setState({
										refuseModalVisible: true
									})

								}}>
									<Text style={styles.btnEmpty}>驳回</Text>
								</TouchableOpacity>
							</View>
						</View>


					</View>
				</View>
			</View>
		)
	}


	//sing- 同意 驳回
	_fetchApprovalSing = async () => {
		const { choice } = this.state;
		const { corpId } = choice || {};
		// 参数
		sendApprovalDateSing.formKey = this.formKey;
		sendApprovalDateSing.taskId = this.taskId;
		sendApprovalDateSing.taskName = this.taskName;
		sendApprovalDateSing.businessKey = this.businessKey;
		if (this.requesting) return;
		sendApprovalDateSing['remark'] = sendApprovalDateSing['auditRemark'] == 'undefined' ? '' : sendApprovalDateSing['auditRemark'];
		sendApprovalDateSing['auditResult'] = sendApprovalDateSing['approvalType'] == 'PASS' ? 1 : 0;

		const { approvalType } = sendApprovalDateSing;

		this.setState({
			refuseModalVisible: false,
		});
		let remark = (sendApprovalDateSing['remark'] + "").trim();
		if (sendApprovalDateSing['approvalType'] != 'PASS') {
			if (!sendApprovalDateSing['remark'] || remark.length == 0) {
				ToastUtil.showError('请输入驳回原因');
				return;
			}
		}

		this.requesting = true;
		sendApprovalDateSing.corpId = corpId;
		const responseData = await HTTP.POST(API_GENERATE(API.APPRO_PRICE), sendApprovalDateSing);
		const msg = (approvalType == 'PASS') ? '审批成功' : '驳回成功';
		if (responseData) {
			ToastUtil.showSuccess(msg).then(() => { this.requesting = false; this._getListData(); });
		} else {
			this.requesting = false;
		}
	}

	// sing-同意
	_agreeFn = (formKey, taskId, businessKey) => {
		this.formKey = formKey;
		this.taskId = taskId;
		this.businessKey = businessKey;
		Alert.alert('审批确认', `确认审批该现货价提报单吗?`, [
			{ text: '取消', onPress: () => { console.log('取消') } },
			{
				text: '确认', onPress: () => {
					sendApprovalDateSing.approvalType = 'PASS';
					this._fetchApprovalSing()
				}
			},
		]);
	}

	_showVisible = () => {
		if (this.state.modalVisible) {
			this.setState({
				modalVisible: false
			})
		} else {
			this.setState({
				modalVisible: true
			})
		}
	}


	_itemFn = (index) => {
		console.log('sendObj', index)
		let { companyData } = this.state || {};
		this.headIndex = index;
		this.department = companyData[index].dictName;
		sendData.organId = companyData[index]['dictKey'];
		this.state.status = 'loading';
		this.setState({
			modalVisible: false
		}, () => { this._getListData(); })
	}

	_modal = () => {
		const { options } = this.state;
		return (
			/* 头部弹框 */
			<Common styleOut={options.length > 1 ? styles.modelOutWidthChoice : styles.modelOut} itemFn={this._itemFn} data={this.headData} imgIndex={this.headIndex} allClick={this._showVisible} type="selectModal" />
		)
	}

	_showVisible() {
		if (this.state.modalVisible1) {
			this.setState({
				modalVisible1: false
			})
		} else {
			this.setState({
				modalVisible1: true
			})
		}
	}

	simpleFormatAsMoney(mnt) {
		mnt = mnt ? (Math.round(mnt * 100)) / 100 : undefined;
		return (mnt == Math.floor(mnt)) ? mnt + '.00' : ((mnt * 10 == Math.floor(mnt * 10)) ? mnt + '0' : mnt);
	}




	//公共驳回函数
	_rejectAll = () => {
		let count = 0;
		let { applyIdChecked } = this.state;
		for (var key in applyIdChecked) {
			var checkOff = applyIdChecked[key];
			if (checkOff) {
				count++;
			}
		}
		if (count == 0) {
			ToastUtil.showWarning('请至少选择一条记录操作!');
			return;
		} else if (count > maxCount) {
			ToastUtil.showWarning('一次最多操作' + maxCount + '条记录!');
			return;
		} else {
			sendApprovalDate.approvalType = 'UNPASS';
			this._fetchApproval();
		}
	}


	// 公共同意函数
	async _fetchApproval() {
		if (this.requesting) return;
		const { approvalType } = sendApprovalDate;
		//alert(approvalType);
		const { applyIdChecked, newLotData, choice } = this.state;
		const { corpId } = choice || {};
		var shenPi = approvalType == 'UNPASS' ? 0 : 1;
		var count = 0;
		let taskList = {};
		var countList = [];
		newLotData.forEach((item, i) => {
			var applyId = item['businessKey'];//任务主键
			var taskId = item['taskId'];
			var formKey = item['formKey'];//
			taskList[taskId] = { businessKey: applyId, taskName: item.taskName, taskId: taskId, formKey: formKey, auditResult: shenPi };
		});
		for (var key in applyIdChecked) {
			var checkOff = applyIdChecked[key];
			count += checkOff * 1;
			if (checkOff == 1) {
				countList[countList.length] = taskList[key];
			}
		}
		this.setState({
			refuseModalVisible: false,
			selectCheck: false,
		});
		if (count == 0) {
			ToastUtil.showWarning('请至少选择一条记录操作!');
			return;
		} else if (count > maxCount) {
			ToastUtil.showWarning('一次最多操作' + maxCount + '条记录!');
			return;
		} else {
			//console.log('countList000000', countList);
			//let condition = { taskList: countList };
			sendApprovalDate.taskList = countList;
			//const responseData = [];
			this.requesting = true;
			sendApprovalDate.corpId = corpId || '';
			const responseData = await HTTP.POST(API_GENERATE(API.APPRO_PRICE_BATCH), sendApprovalDate);
			const msg = (approvalType == 'UNPASS') ? '批量驳回成功' : '批量审批成功';
			console.log(responseData, 'responseData111')
			if (responseData) {
				ToastUtil.showSuccess(msg).then(() => {
					this.requesting = false;
					this._getListData();
				})
			} else {
				this.requesting = false;
			}
		}
	}

	//关闭审批状态弹框
	_closeLightBox = () => {
		this.stateLightBoxData.modalVisible = false;
		this.setState({
			ls: false
		});
	}

	//审批流程
	_stepFn = async (applyId, processInstanceId) => {
		let { choice } = this.state;
		let params = {
			bizId: applyId,
			bizObjType: 14,
			processInstanceId: processInstanceId,
			corpId: choice.corpId || null
		}
		let responseData = await QuoteService.quoteStatus(params);
		this.stateLightBoxData.rowDataList = responseData;
		this.stateLightBoxData.modalVisible = true;

		this.setState({
			ls: true
		})
	}


	_resultCall = (resultData) => {
		this.setState({
			timeStart: resultData.startTime,
			timeEnd: resultData.endTime,
			timeModel: false
		}, () => {
			this._getListData();
		})
	}


	_renderToastWrap = () => {
		return (
			<View>
				<Text style={{ paddingBottom: 5 * scale }}>触发审批的涨跌幅取值逻辑：</Text>
				<Text>“本次提交现货价” 较 “昨日现货价、上次现货价” 涨跌绝对值中取最大</Text>
			</View>
		)
	}


	_closeModal = () => {
		this.setState({ modalVisible: false });
	}


	render() {
		let { selectCheck, refuseModalVisible, tabIndex, companyData, status,
			timeModel, timeStart, timeEnd, modalRemark, alertShow, choice, options, modalInfoVisible, modalVisible } = this.state;

		let rightImg = require('../../../imgs/global/success.png');
		let emptyImg = require('../../../imgs/global/option.png');
		const searchLeft = require('../../../imgs/global/whiteSearch.png');
		return (
			<View style={styles.container}>
				<NavigationEvents onWillFocus={async () => {
					// await this.getSorage();
					await this._getListData()
				}}
				/>

				<View style={styles.headBox}>
					<View style={styles.outSearch}>
						<View style={styles.nerSearch}>
							<SearchInput
								placeholder={'请输入商品名称'}
								inputLeftIcon={searchLeft}
								setKeyWord={(txt) => { this.goodsName = txt; if (txt.length == 0) { this.goodsName = null; this._getListData(); } }}
								onSubmitEditing={(txt) => { this._getListData() }}
								inputViewStyle={styles.searchStyle}
								inputStyle={{ fontSize: 14 * scale, color: "#fff" }}
								placeholderTextColor="rgba(255, 255, 255, .8)"
								inputLeftIconStyle={styles.searchLeftIconStyle}

							/>
						</View>
					</View>
				</View>
				{options.length > 1 ?
					<NewAccountHome
						fn={(val) => {
							this.setState({ companyIndex: val }, async () => {
								this.pageNo = 1;
								await this._getCompanyData();
								await this._isLoadRefresh();
							})
						}}
						options={options}
						choice={choice} />
					: null}
				<View style={styles.listBox}>
					<View style={styles.listScreen}>
						<TouchableOpacity onPress={this._showVisible} style={styles.flexRow}>
							<Text style={styles.allBtn}>{this.department || '全部'}</Text>
							<Image source={require('../../../imgs/select.png')} />
						</TouchableOpacity>
						<TouchableOpacity onPress={() => { this.setState({ timeModel: !timeModel }) }} style={styles.timeRight}>
							<Text style={styles.timeTitle}>提报时间</Text>
							<Text style={styles.timeValue}>{timeStart || '开始时间'} / {timeEnd || '结束时间'}</Text>
						</TouchableOpacity>
					</View>


					{
						status == 'data' ? (<FlatList style={tabIndex == 0 ? { marginBottom: 54 * scale, } : null}
							data={this.state.newLotData}
							renderItem={(data) => this._renderItem(data)}
							refreshing={this.state.loadIcon}
							onRefresh={this._isLoadRefresh.bind(this)}
							onEndReachedThreshold={1}
							onEndReached={() => { this._loadData() }}
						/>) : <PageStatusIndex status={status} emptyText="暂无记录" onErrorPress={this._onErrorPress} />
					}


					<RefuseModal visible={refuseModalVisible}
						titleText={this.isAgree ? '同意原因' : null}
						placeholderText={this.isAgree ? '请输入同意原因' : null}
						btnPress={(auditRemark) => {
							sendApprovalDateSing.approvalType = this.isAgree ? 'PASS' : 'UNPASS';
							//sendApprovalDateSing.approvalType = 'UNPASS';
							sendApprovalDateSing.auditRemark = auditRemark;
							this._fetchApprovalSing();
						}} bgPress={() => {
							this.setState({
								refuseModalVisible: false,
							});
						}} />
				</View>



				{this.state.newLotData.length > 0 && tabIndex == 0 ? (
					<View style={styles.botContainer}>
						<View style={[styles.bombList, styles.marLeft]} >
							<TouchableOpacity onPress={this._checkAll.bind(this)}>
								<View style={{ flexDirection: 'row' }}>
									<Image style={styles.bombImg} source={selectCheck ? rightImg : emptyImg} />
									<Text style={styles.bombTextFont}>全选</Text>
								</View>
							</TouchableOpacity>
							<View style={{ flexDirection: 'row' }}>
								<TouchableOpacity style={styles.rejectBotton} onPress={() => {
									this._rejectAll();
								}}>
									<Text style={styles.rejectText}>驳回</Text>
								</TouchableOpacity>
								<TouchableOpacity style={styles.agreeBotton} onPress={() => {
									sendApprovalDate.approvalType = 'PASS';
									this._fetchApproval();
								}} >
									<Text style={styles.agreeText}>同意</Text>
								</TouchableOpacity>
							</View>
						</View>
					</View>) : null}
				{/* {this.state.modalVisible ? this._modal() : null} */}
				<Common type="modal" demoData={(
					<Common type="listRadio" selectIndex={this.headIndex} title={'请选择授权部门'} listData={companyData || []} selectCallBack={this._itemFn} />
				)} isVisible={modalVisible} closeCallballFn={this._closeModal} />

				{modalRemark ? (<Common type="modal" demoData={this._retuenMarkModel()} modelClick={this._closeMarkModel} closeCallballFn={this._closeMarkModel} />) : null}
				<StateLightBox  {...this.stateLightBoxData} textStyle={{ marginLeft: 15 * scale, marginRight: 5 * scale }} />
				{
					timeModel ? <RangTime isVisible={true} markedDates={null} startTime={timeStart} endTime={timeEnd} resultCall={this._resultCall} /> : null
				}

				{/* <SlideSelect alertShow={alertShow} options={options}
					select={(val) => {
						this.setState({ choice: val || options[0], alertShow: false }, async () => {
							await this._getCompanyData();
							this._isLoadRefresh();
						})
					}}
					unselect={() => {
						this.setState({ alertShow: false })
					}} /> */}
				<CommonDialog modalVisible={modalInfoVisible} title={'提示'} renderCustom={this._renderToastWrap} onClosePress={() => { this.setState({ modalInfoVisible: false }) }} />

			</View >
		)
	}
}
const styles = StyleSheet.create({
	container: {
		flex: 1,
		backgroundColor: '#EEF1FA',
	},
	listBox: {
		flex: 1,
	},
	tabTop: {
		height: 40 * scale,
		backgroundColor: style.color.themeColor,
		flexDirection: 'row'
	},
	TabText: {
		fontSize: 14 * scale,
		color: style.color.white,
		textAlign: 'center'
	},
	listItem: {
		width: '100%',
		paddingTop: 12 * scale,
		paddingBottom: 12 * scale,
		flexDirection: 'row',
		borderBottomWidth: 1 / PixelRatio.get(),
		borderStyle: 'solid',
		borderBottomColor: style.color.gray,
	},
	leftImg: {
		width: 40 * scale,
		height: 40 * scale,
		marginLeft: 15 * scale
	},
	conent: {
		width: 265 * scale,
		paddingLeft: 15 * scale
	},
	rightText: {
		color: '#2F7BFF'
	},
	titleBox: {
		flexDirection: 'row',
		alignItems: 'center',
		marginBottom: 5 * scale
	},
	title: {
		fontSize: 14 * scale,
		color: '#222',

	},
	infoText: {
		fontSize: 12 * scale,
		color: '#8b8b8b'
	},
	tabBox: { width: '50%', height: 40 * scale, marginTop: 5 * scale, alignItems: 'center', justifyContent: 'space-between' },
	elementImg: {
		width: 21 * scale,
		height: 14 * scale,
		marginLeft: 5 * scale
	},

	list: {
		backgroundColor: style.color.white,
		marginBottom: 12 * scale
	},
	listUp: {
		height: 44 * scale,
		width: 351 * scale,
		flexDirection: 'row',
		alignItems: 'center',
		justifyContent: 'space-between',
		borderBottomWidth: 1 / PixelRatio.get(),
		borderStyle: 'solid',
		borderBottomColor: style.color.border,
		marginLeft: 12 * scale,
		//mrginRight: 12 * scale,
	},
	listDown: {
		width: 351 * scale,
		marginLeft: 12 * scale,
		flexDirection: 'row',
	}, listMrigin: {
		marginTop: 12 * scale,
	},
	borderStart: {
		marginTop: 4 * scale,
		//paddingBottom: 12 * scale,
	}, borderEnd: {
		marginTop: 4 * scale,
		paddingBottom: 12 * scale,
	}, borderBot: {
		borderBottomWidth: 1 / PixelRatio.get(),
		borderStyle: 'solid',
		borderBottomColor: style.color.border,
	},
	listDownTe: {
		marginBottom: 16 * scale,
		paddingLeft: 15 * scale,
		paddingRight: 15 * scale,
		flexDirection: 'row',
	},
	listTitle: {
		width: 280 * scale,
		marginLeft: 6 * scale,
		flexDirection: 'row',
		fontSize: 14 * scale,
		color: style.color.dark,
	},
	listTitle1: {
		width: 286 * scale,
		flexDirection: 'row',
		fontSize: 14 * scale,
		color: style.color.dark,
	},
	listTime: {
		fontSize: 12 * scale,
		color: '#8B8B8B'
	}, statusText: {
		fontSize: 13 * scale,
		color: style.color.themeColor,
	}, listText: {
		width: '50%',
		color: style.color.normal,
		fontSize: 12 * scale,
		height: 17 * scale,
	}, listInner: {
		width: '50%',
		flexDirection: 'row',
		alignItems: 'center'
	},
	botContainer: {
		flex: 1,
		backgroundColor: "#fff",
		borderTopColor: "#E4E4E4",
		borderStyle: "solid",
		borderTopWidth: 1 / PixelRatio.get(),
		height: 54 * scale,
		width: 375 * scale,
		position: 'absolute',
		bottom: 0,
		left: 0,
	},
	bombBody: {
		flexDirection: 'row',
		alignItems: 'center'
	},
	bombTitle: {
		fontSize: 12 * scale,
		color: style.color.darkGray,
		paddingTop: 15 * scale,
		paddingBottom: 18 * scale
	},
	bombList: {
		flexDirection: 'row',
		justifyContent: 'space-between',
		alignItems: 'center',
		height: 54 * scale,
	},
	bombImg: {
		marginTop: 2 * scale,
		width: 14 * scale,
		height: 14 * scale,
	},
	bombTextFont: {
		fontSize: 14 * scale,
		color: '#8B8B8B',
		marginLeft: 7 * scale,
	},
	selectStyle: {
		width: 13 * scale,
		height: 7 * scale,
		marginLeft: 5 * scale
	},
	close: {
		position: 'absolute',
		right: 15 * scale,
		top: 15 * scale,
	},
	rejectBotton: {
		marginRight: 10 * scale,
		borderRadius: 15 * scale,
		height: 30 * scale,
		width: 64 * scale,
		justifyContent: 'center',
		alignItems: 'center',
		borderColor: "#0087FF",
		borderStyle: "solid",
		borderWidth: 1 * scale,
	},
	rejectText: {
		fontSize: 13 * scale,
		color: '#0087FF',
	},
	agreeBotton: {
		marginRight: 8 * scale,
		borderRadius: 15,
		height: 30 * scale,
		width: 64 * scale,
		justifyContent: 'center',
		alignItems: 'center',
		backgroundColor: '#0087FF',
	},
	agreeText: {
		fontSize: 13 * scale,
		color: '#FFFFFF',
	},
	marLeft: {
		marginLeft: 13 * scale,
	},
	text: {
		fontSize: 13 * scale,
		color: '#404040'
	},
	refuseBtn: {
		justifyContent: 'center',
		alignItems: 'center',
		width: '100%',
		height: 38 * scale,
		backgroundColor: style.color.themeColor,
		borderRadius: 100,
	},
	refuseBtnText: {
		fontSize: 16 * scale,
		color: '#fff'
	},
	reasonTextInput: {
		marginTop: 10 * scale,
		marginBottom: 18 * scale,
		width: '100%',
		height: 80 * scale,
		backgroundColor: '#F9FAFA',
		borderRadius: 3,
		paddingTop: 5 * scale,
		paddingBottom: 3 * scale,
		paddingLeft: 5 * scale,
		paddingRight: 3 * scale,
		fontSize: 13 * scale,
		textAlignVertical: 'top'
	},
	refuseModal: {
		width: 375 * scale,
		height: GLOBAL.SCREEN_HEIGHT,
		backgroundColor: 'rgba(0, 0, 0, .3)',
		alignItems: 'center',
	},
	top: {
		height: 190 * scale,
		width: 375 * scale,
		backgroundColor: 'transparent',
	},
	bottom: {
		// flex: 1,
		width: 375 * scale,
		height: 280 * scale,
		backgroundColor: 'transparent',
	},
	refuseBox: {
		backgroundColor: '#fff',
		borderRadius: 9,
		width: 282 * scale,
		// justifyContent: 'center',
		alignItems: 'center',
	},
	refuseCell: {
		width: 258 * scale,
		paddingTop: 15 * scale,
		paddingBottom: 10 * scale,
	},
	bottomBtnCell: {
		width: 375 * scale,
		height: 60 * scale,
		flexDirection: 'row',
		borderTopColor: '#e4e4e4',
		borderTopWidth: 1 / PixelRatio.get(),
		backgroundColor: '#fff',
	},
	bottomBtn: {
		justifyContent: 'center',
		flex: 1,
	},
	bottomBtnPic: {
		marginRight: 20 * scale,
	},
	bottomBtnView: {
		flexDirection: 'row',
		justifyContent: 'center',
		alignItems: 'center',
	},
	bottomBtnViewLeft: {
		borderRightColor: '#e4e4e4',
		borderRightWidth: 1 / PixelRatio.get(),
	},
	bottomBtnText: {
		fontSize: 18 * scale,
		color: '#404040'
	}, selectViewOne: {
		width: '50%',
		flexDirection: 'row',
		alignItems: 'center',
	}, selectViewTwo: {
		width: '33%',
		flexDirection: 'row',
		alignItems: 'center',
	}, showOne: {
		display: 'none',
	}, showTwo: {
		display: 'flex',
	},
	headBox: {
		backgroundColor: style.color.themeColor,
		height: 55 * scale,
		width: '100%',
	},
	outSearch: {
		height: 36 * scale,
		width: '100%',
		flexDirection: 'row',
		justifyContent: 'center',
	},
	nerSearch: {
		height: 36 * scale,
		width: '80%',
	},
	searchStyle: {
		height: 36 * scale,
		width: 270 * scale,
		paddingLeft: 90 * scale,
		paddingRight: 12 * scale,
		backgroundColor: 'rgba(255, 255, 255, .18)',
		flexDirection: 'row',
		justifyContent: 'center',
		alignItems: 'center',
		paddingVertical: 0,
		position: 'relative',
		borderRadius: 8 * scale
	},
	searchLeftIconStyle: {
		width: 20 * scale,
		height: 20 * scale,
		position: 'absolute',
		left: 30 * scale,
		top: 8 * scale,
		zIndex: 9,
		opacity: 0.8,
	},
	listScreen: {
		flexDirection: 'row',
		justifyContent: 'space-between',
		alignItems: 'center',
		height: 60 * scale,
		paddingLeft: 20 * scale,
		paddingRight: 20 * scale
	},
	flexRow: {
		flexDirection: 'row',
		alignItems: 'center',
	},
	allBtn: {
		color: '#0E7FFD',
		fontWeight: 'bold',
		marginRight: 10 * scale
	},
	timeRight: {
		width: 150 * scale,
		justifyContent: 'flex-end'
	},
	timeTitle: {
		fontSize: 14 * scale,
		color: '#848A96',
		textAlign: 'right'
	},
	timeValue: {
		fontSize: 12 * scale,
		color: style.color.atrous,
		textAlign: 'right'
	},
	modelOutWidthChoice: { top: 138 * scale },
	modelOut: { top: 110 * scale },
	itemBox: {
		width: 350 * scale,
		backgroundColor: style.color.white,
		borderRadius: 6 * scale,
		paddingBottom: 18 * scale,
		marginBottom: 24 * scale
	},
	itemBoxHeadView: {
		borderBottomColor: '#e4e4e4',
		borderBottomWidth: 1 / PixelRatio.get(),
		backgroundColor: '#fff',
		flexDirection: 'column',
		justifyContent: 'flex-start',
	},
	itemBoxHead: {
		height: 40 * scale,
		backgroundColor: '#fff',
		flexDirection: 'row',
		justifyContent: 'space-between',
		alignItems: 'center',
		paddingLeft: 12 * scale,
		paddingRight: 12 * scale,
		borderRadius: 6 * scale,
		// marginBottom: 10 * scale
	},
	itemBody: {

	},
	itemHeadTitle: {
		fontSize: 16 * scale,
		color: '#555',
		paddingLeft: 3 * scale
	},
	itemHeadTime: {
		fontSize: 14 * scale,
		color: '#555',
	},
	itemForm: {
		flexDirection: 'row',
		justifyContent: 'space-between',
		paddingTop: 18 * scale,
		paddingLeft: 12 * scale,
		paddingRight: 12 * scale
	},
	itemForm2: {
		flexDirection: 'row',
		justifyContent: 'space-between',
		paddingTop: 18 * scale,
		paddingLeft: 12 * scale,
		paddingRight: 12 * scale
	},
	itemFormItem: {
		//flexDirection: 'row',
	},
	itemFormItem2: {
		flexDirection: 'row',
	},
	itemFormTitle: {
		fontSize: 12 * scale,
		paddingBottom: 5 * scale,
	},
	itemFormText: {
		fontSize: 14 * scale
	},
	itemFormTextRed: {
		color: '#D0021B',
		fontSize: 14 * scale
	},
	itemFormTextBlue: {
		color: '#64cdb3',
		fontSize: 14 * scale
	},
	itemFormTextThem: {
		color: style.color.themeColor,
		fontWeight: 'bold'
	},
	btnBoxParent: {
		flexDirection: 'row',
		justifyContent: 'space-between',
		alignItems: 'center',
		paddingLeft: 15 * scale
	},
	btnBox: {
		flexDirection: 'row',
		height: 28 * scale,
		paddingLeft: 12 * scale,
		paddingRight: 12 * scale,
		justifyContent: 'flex-end',
	},
	btnBlueBox: {
		width: 64 * scale,
		height: 30 * scale,
		borderRadius: 15 * scale,
		backgroundColor: style.color.themeColor,
		marginRight: 10 * scale
	},
	btnBlue: {
		width: 64 * scale,
		height: 30 * scale,
		lineHeight: 30 * scale,
		textAlign: 'center',
		color: '#fff',
	},
	btnEmptyBox: {
		borderColor: style.color.themeColor,
		borderWidth: 1 / PixelRatio.get(),
		backgroundColor: '#fff',
		width: 66 * scale,
		height: 28 * scale,
		borderRadius: 6 * scale,
	},
	btnEmptyBox: {
		borderRadius: 15 * scale,
		width: 64 * scale,
		height: 30 * scale,
	},
	btnEmpty: {
		color: style.color.themeColor,
		textAlign: 'center',
		lineHeight: 30 * scale,
	},
	markBox: {
		width: 300 * scale,
		height: 260 * scale,
		backgroundColor: style.color.white,
		borderRadius: 13 * scale,
	},
	markTitle: {
		fontSize: 18 * scale,
		textAlign: 'center',
		color: style.color.dark,
		marginTop: 15 * scale
	},
	markBody: {
		fontSize: 12 * scale,
		lineHeight: 26 * scale,
		padding: 20 * scale
	},
	accountSelect: {
		backgroundColor: style.color.themeColor,
		flexDirection: 'row',
		alignItems: 'center',
		justifyContent: 'center'
	},
	tipTextBox: {
		paddingLeft: 5 * scale,
		paddingRight: 5 * scale,
		marginLeft: 20 * scale
	},
	tipText: {
		height: 15 * scale,
		width: 15 * scale,
	},
	flex1: {
		flex: 1
	},
	flex2: {
		flex: 2
	},
	itemLine: {
		flexDirection: 'row',
	},
	itemLineB: {
		justifyContent: 'space-between'
	},
	itemLineNum: { fontWeight: 'bold', fontSize: 14 * scale, color: '#000' },
	itemLineLay: { fontSize: 13 * scale, color: '#555', width: 85 * scale, textAlign: 'right', marginRight: 20 * scale },
	itemLineVal: { fontSize: 13 * scale, color: '#555' },
	felxPadding: {
		flexDirection: 'row',
	},
	flexLine: {
		flexDirection: 'row',
		paddingRight: 120 * scale,
	},
	itemName: {
		flexDirection: 'row',
	},
	itemLineActive: { color: '#000' },
	padding: { height: 30 * scale, paddingLeft: 10 * scale, paddingRight: 15 * scale },
	itemLineTime: { fontSize: 10 * scale, paddingTop: 3 * scale }
})